package com.fansl.koala.quickdev.common;

import com.fansl.koala.quickdev.common.annation.DecryptParam;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.util.WebUtils;
import reactor.netty.http.server.HttpServerRequest;

import javax.servlet.http.HttpServletRequest;

/**
 * @author fansl
 * @Description: TODO
 * @date 2020/3/20 14:31
 */
@Aspect
@Slf4j
@Component
public class DecryptParamAspect {
    @Pointcut("@annotation(com.fansl.koala.quickdev.common.annation.DecryptParam)")
    public void decryptParam(){
    }
    @SneakyThrows
    @Around("decryptParam()")
    public Object doBefore(ProceedingJoinPoint proceedingJoinPoint){
        Signature signature = proceedingJoinPoint.getSignature();
        MethodSignature methodSignature = (MethodSignature) signature;
        DecryptParam decryptParam = methodSignature.getMethod().getAnnotation(DecryptParam.class);
        if (decryptParam==null){
            System.out.println(decryptParam);
        }

        return proceedingJoinPoint.proceed();
    }
}
